package ex.algorithms.datastructures;

import java.util.ArrayList;
import java.util.List;

public class Queue {
	private int head = 0;
	private int tail = 0;
	private int length;
	private int[] items;
	
	public Queue(int length) {
		this.length = length;
		items = new int[length];
	}
	
	public void enqueue(Integer i) {
		tail ++;
		
		if((tail - head) > length) {
			System.out.println("Queue full");
			return;
		}
			
		
		items[(tail - 1) % length] = i;
	}
	
	public Integer dequeue() {
		
		if(head >= tail)
			return null;
		
		head ++;
		
		return items[(head - 1) % length];
	}
}
